 
 <#-- 
 
 crea una clase para c# para la tabla  ${table}...
 Author : Luis Molina...
 
 -->
<#-- variables used internally by the generator... -->
<#assign nameFile="${table}">
<#assign extensionFile="cs">
<#assign languageGenerated="c#">
<#assign description="c#">
<#assign targetDirectory="">
<#assign appliesToAllTables="true">
<#-- END variables used internally by the generator... -->


	using System;
	using System.Collections;
    using System.Web;
    using System.Collections.Generic;
    using System.ComponentModel; 
    
    
public partial class ${table} 
	{
	#region["Variables"]
		 
		 
	<#list table.getFields() as field>
		
		 <#-- segun el tipo de campo...   -->
		 <#switch field.getType()>
			  <#case "_int">
			     private int _${field};
			     <#break>
			  <#case "_string">
			     private string _${field};
			     <#break>
			  <#case "_date">
			     private DateTime _${field};
			     <#break>
			  <#case "_boolean">
			     private bool _${field};
			     <#break>
			 <#case "_float">
			     private double _${field};
			     <#break>
			  <#default>
			     private string _${field};
		</#switch>  
	 
	</#list>
	
	#endregion
	
	
	#region["Propiedades"]
	
	
	<#list table.getFields() as field>
		<#if (field.getisKey())>
				// for the objectDataSource
				[DataObjectField(true,true)]
        </#if>
		 <#-- segun el tipo de campo...   -->
		 <#switch field.getType()>
			  <#case "_int">
			      public int ${field}
		                {
			                get {return _${field};}
			                set {_${field} = value;}
		                }
			     <#break>
			  <#case "_string">
			      public string ${field}
		                {
			                get {return _${field};}
			                set {_${field} = value;}			                
		                }
			     <#break>
			  <#case "_date">
			       public DateTime ${field}
		                {
			                get {return _${field};}
			                set {_${field} = value;}
		                }
			     <#break>
			  <#case "_boolean">
				  public bool ${field}
						{
							get {return _${field};}
							set {_${field} = value;}			                
						}
			     <#break>
			  <#case "_float">
				  public double ${field}
						{
							get {return _${field};}
							set {_${field} = value;}			                
						}
			     <#break>
			  <#default>
			      public string ${field}
		                {
			                get {return _${field};}
			                set {_${field} = value;}			                
		                }
		</#switch>  
		
	</#list>	
	
    #endregion
  

    public ${table}()
		{
		}

    public static void Delete(${table.getListParameters()})
    {	
		String sql="";
		dbClass db = new dbClass(ctes.conStringAdoGeneral);
        try { 
        sql= @" delete from ${table} 
					where 1!=0        
        <#assign count=0>	
        <#list table.getFields() as field>
            <#if (field.getisKey())>
                <#if (field.getType()=="string")>
                     and ${field}='" + sf.cadenaSqlServer(${field})';
                <#else>
                     and ${field}=" + sf.cadenaSqlServer(${field});
                </#if>
            </#if>
         <#assign count = count+1>
		</#list>
           db.ejecutar(sql);

           }
           catch (Exception ex)
           {
               // Argument is optional, no "When" keyword 
           }
           finally
           {
               db.Dispose();

           }
    } //  Delete

	
    public static void DeleteAll()
    {
        string sqlt;
        dbClass db = new dbClass(ctes.conStringAdoGeneral);
        try { 
        sqlt = " delete from ${table} ";
        db.ejecutar(sqlt);
		}
           catch (Exception ex)
           {
               // Argument is optional, no "When" keyword 
           }
           finally
           {
               db.Dispose();
           }
    } // DeleteAll
	
	
	
    public static string Insert(${table} obj${table})
    {
        String sql="";
        string retorno = "";
        dbClass db = new dbClass(ctes.conStringAdoGeneral);
        System.Data.SqlClient.SqlDataReader reg;
        try
        {
        sqlt= @" insert into x${table} ( ${table.getlistWithAllFieldsExceptKeys()} )  
                 values (
			<#assign count=0>	
			<#list table.getFields() as field> 
				<#if (!field.getisKey())>
					 <#-- segun el tipo de campo...   -->
					 <#switch field.getType()>
							  <#case "_int">
			 					  " + sf.cadenaSqlServer(obj${table}.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>, </#if>   
								 <#break>
							  <#case "_string">
								   " + sf.cadenaSqlServer(obj${table}.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>, </#if>   
								 <#break>
							  <#case "_date">
								   " + sf.cadenaSqlServer(obj${table}.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>, </#if>    
								 <#break>
							  <#case "_boolean">
								  " + sf.cadenaSqlServer(obj${table}.${field})  + @" <#if (table.getNumberOfFields() -  count  != 1)>, </#if>  
								 <#break>
							  <#case "_float">
								   " + sf.cadenaSqlServer(obj${table}.${field})  + @" <#if (table.getNumberOfFields() -  count  != 1)>, </#if>  
								 <#break>
							  <#default>
								   " + sf.cadenaSqlServer(obj${table}.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>, </#if>  
					</#switch>  
				</#if>
			 <#assign count = count+1>
			</#list>	 
			  )" ;

            db.ejecutar(sql);
            reg = db.sql("select @@identity as id from ${table}");
            if (reg.Read())
                {
                  retorno = sf.cadena(reg["id"].ToString());
                }
                reg.Close();
            }
                 
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return retorno;
       } //insert


		// devuelve una lista de ${table}
 
 		public static List< ${table} > getList()
		{
		    List< ${table} > lista${table} = new List< ${table} >();
            System.Data.SqlClient.SqlDataReader reg;
            string sqlt;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select ${table.getListWithAllFields()} from ${table}";
            reg = db.sql(sqlt);
            while (reg.Read())
                {
                ${table} pp = new ${table}();
				<#list table.getFields() as field> 
					 <#-- segun el tipo de campo...   -->
					 <#switch field.getType()>
						  <#case "_int">
							 pp.${field} = sf.entero(reg["${field}"].ToString());
							 <#break>
						  <#case "_string">
							 pp.${field} = sf.cadena(reg["${field}"].ToString());
							 <#break>
						  <#case "_date">
							 pp.${field} = sf.fecha(reg["${field}"].ToString());
							 <#break>
						  <#case "_boolean">
							 pp.${field} = sf.boolean(reg["${field}"].ToString());
							 <#break>
						 <#case "_float">
							 pp.${field} = sf.doble(reg["${field}"].ToString());
							 <#break>
						  <#default>
							 pp.${field} = sf.cadena(reg["${field}"].ToString());
					</#switch>   
				</#list>
               lista${table}.Add(pp);

               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return lista${table};
       } // getList

 
 
 // devuelve una lista de ${table}
 
 		public static List< ${table} > getListByBusquedaGeneral(String cadena)
		{
		    List< ${table} > lista${table} = new List< ${table} >();
            System.Data.SqlClient.SqlDataReader reg;
            string sqlt;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
           sqlt = @"select ${table.getListWithAllFields()} from ${table} where 1!=0  and (              
			<#assign countx=0>				
			<#list table.getFields() as field> 
				<#-- segun el tipo de campo...   -->
				<#switch field.getType()>
					  <#case "_int">					  
						 <#break>
					  <#case "_string">
						<#if (countx==0)>
							 ${field} like '%" + cadena + @"%' 	
							<#assign countx = countx+1>
						<#else>
							 or ${field} like '%" + cadena + @"%'
						</#if>				  
						<#break>
					  <#case "_date">					 
						 <#break>
					  <#case "_boolean">					 
						 <#break>
					  <#default>					 
				</#switch>  
			</#list>
			)";  
						
			
            reg = db.sql(sqlt);
            while (reg.Read())
                {
                ${table} pp = new ${table}();
       

<#list table.getFields() as field> 
	 <#-- segun el tipo de campo...   -->
	 <#switch field.getType()>
		  <#case "_int">
		     pp.${field} = sf.entero(reg["${field}"].ToString());
		     <#break>
		  <#case "_string">
		     pp.${field} = sf.cadena(reg["${field}"].ToString());
		     <#break>
		  <#case "_date">
		     pp.${field} = sf.fecha(reg["${field}"].ToString());
		     <#break>
		  <#case "_boolean">
		     pp.${field} = sf.boolean(reg["${field}"].ToString());
		     <#break>
		  <#case "_float">
		     pp.${field} = sf.doble(reg["${field}"].ToString());
		     <#break>
		  <#default>
		     pp.${field} = sf.cadena(reg["${field}"].ToString());
	</#switch>   
</#list>

               lista${table}.Add(pp);

               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return lista${table};
       }	//getListByBusquedaGeneral	
 
 		public static ${table} get${table}(${table.getListParameters()})
		{
            ${table} ${table}x = new ${table}();
            System.Data.SqlClient.SqlDataReader reg;
            string sqlt;
                ${table} obj${table} = new ${table}();


            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = @"    select ${table.getListWithAllFields()} from ${table} where 1!=0 
            <#list table.getFields() as field>
              <#if (field.getisKey())>   
                     <#-- segun el tipo de campo...   -->
                     <#switch field.getType()>
                              <#case "_int">
                                 and ${field}=" + sf.cadenaSqlServer(${field}) + @"
                                 <#break>
                              <#case "_string">
                                  and ${field}=" + sf.cadenaSqlServer(${field}) + @"
                                 <#break>
                              <#case "_date">
                                 and ${field}=" + sf.cadenaSqlServer(${field}) + @"
                                 <#break>
                              <#case "_boolean">
                                 and ${field}=" + sf.cadenaSqlServer(${field}) + @"
                                 <#break>
                              <#case "_float">
                                 and ${field}=" + sf.cadenaSqlServer(${field}) + @"
                                 <#break>
                              <#default>
                                  and ${field}=" + sf.cadenaSqlServer(${field}) + @";
                    </#switch>  
              </#if>
            </#list>
					";
            reg = db.sql(sqlt);
            if (reg.Read())
            {
          
              <#list table.getFields() as field>
                         <#-- segun el tipo de campo...   -->
                         <#switch field.getType()>
                                  <#case "_int">
                                     obj${table}.${field} = sf.entero(reg["${field}"].ToString());
                                     <#break>
                                  <#case "_string">
                                     obj${table}.${field} = sf.cadena(reg["${field}"].ToString());	  					
                                     <#break>
                                  <#case "_date">
                                    obj${table}.${field} = sf.fecha(reg["${field}"].ToString());
                                     <#break>
                                  <#case "_boolean">
                                     obj${table}.${field} = sf.boolean(reg["${field}"].ToString());
                                     <#break>
                                  <#case "_float">
                                     obj${table}.${field} = sf.doble(reg["${field}"].ToString());
                                     <#break>
                                  <#default>
                                     obj${table}.${field} = sf.cadena(reg["${field}"].ToString());	  					
                        </#switch>  
                </#list>		 
           
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return  obj${table} ;
       } //get${table}



 public static bool Update(${table} obj${table})
		{
			String sql="";
            System.Data.SqlClient.SqlDataReader reg;
            System.Text.StringBuilder sqlt = new System.Text.StringBuilder();
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sql= @" update ${table} set 
		<#assign count=0>		
		<#list table.getFields() as field>
			<#if (field.getisKey() || field.getTargetType() == "_image")>
			<#else>
				 <#-- segun el tipo de campo...   -->
				 <#switch field.getType()>
					  <#case "_int">
							  ${field}=" + sf.cadenaSqlServer(obj${table}.${field}) + @"<#if (table.getNumberOfFields() -  count  != 1)>,</#if>
						 <#break>
					  <#case "_string">
						${field}=" + sf.cadenaSqlServer(obj${table}.${field}) + @"<#if (table.getNumberOfFields() -  count  != 1)>,</#if> 
						 <#break>
					  <#case "_date">
						  ${field}=" + sf.fechaIso(obj${table}.${field}) + @"<#if (table.getNumberOfFields() -  count  != 1)>,</#if> " );
						 <#break>
					  <#case "_boolean">
						 ${field}=" + sf.cadenaSqlServer(obj${table}.${field}) + @"<#if (table.getNumberOfFields() -  count  != 1)>,</#if>  
						 <#break>
					  <#case "_float">
						 ${field}=" + sf.cadenaSqlServer(obj${table}.${field}) + @"<#if (table.getNumberOfFields() -  count  != 1)>,</#if> 
						 <#break>
					  <#default>
						 ${field}=" + sf.cadenaSqlServer(obj${table}.${field}) + @"<#if (table.getNumberOfFields() -  count  != 1)>,</#if> 
				</#switch> 		
			</#if>	
			<#assign count = count+1>
		</#list>
		";
             reg = db.sql(sql);
             return (reg!=null);
              }   
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();              
            }
             return true;
       } // Update(${table}
		
			
		
  public void Update()
		{
            System.Data.SqlClient.SqlDataReader reg;
			String sql="";
            System.Text.StringBuilder sqlt = new System.Text.StringBuilder();
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sql= @" update ${table} set 
		<#assign count=0>		
		<#list table.getFields() as field>
			<#if (field.getisKey() || field.getTargetType()=="_image")>
			<#else>
				<#-- segun el tipo de campo...   -->
				 <#switch field.getType()>
					  <#case "_int">
						${field}=" + sf.cadenaSqlServer(this.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>,</#if>  
						 <#break>
					  <#case "_string">
						${field}=" + sf.cadenaSqlServer(this.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>,</#if> 
						 <#break>
					  <#case "_date">
						${field}=" + sf.fechaIso(this.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>,</#if>
						 <#break>
					  <#case "_boolean">
						${field}=" + sf.cadenaSqlServer(this.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>,</#if>
						 <#break>
					  <#case "_float">
						${field}=" + sf.cadenaSqlServer(this.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>,</#if>
						 <#break>
					  <#default>
						${field}=" + sf.cadenaSqlServer(this.${field}) + @" <#if (table.getNumberOfFields() -  count  != 1)>,</#if>						
				</#switch>
			</#if>				
	    <#assign count = count+1>
	    </#list> 
				where 1!=0        
		<#list table.getFields() as field>
			<#if (field.getisKey())>
			 <#-- segun el tipo de campo...   -->
			 <#switch field.getType()>
				  <#case "_int">
						and ${field}=" + this.${field} +@"
					 <#break>
				  <#case "_string">
						and ${field}='" + this.${field} + "'" +@"
					 <#break>
				  <#case "_date">
						and ${field}='" + this.${field} + "'" +@"
					 <#break>
				  <#case "_boolean">
						and ${field}=" + this.${field} +@"
					 <#break>
				  <#default>
						and ${field}='" + this.${field} + "'" +@"
			</#switch>  
		  </#if>
		</#list>
					";
              reg = db.sql(sqlt.ToString());
              }   
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }

       } // Update


// comprueba si existe

 		public static bool exists(${table.getListParameters()} )
		{
           
            System.Data.SqlClient.SqlDataReader reg;
            string sqlt;
            bool retorno=false;
           
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = @"select * from ${table} where 1!=0  
            <#list table.getFields() as field>
                <#if (field.getisKey())>
                     <#-- segun el tipo de campo...   -->
                     <#switch field.getType()>
					  <#case "_int">
						and ${field}=" + sf.cadenaSqlServer(${field}) + @"
						 <#break>
					  <#case "_string">
						and ${field}=" + sf.cadenaSqlServer(${field}) + @"
						 <#break>
					  <#case "_date">
						and ${field}=" + sf.cadenaSqlServer(${field}) + @"
						 <#break>
					  <#case "_boolean">
						and ${field}=" + sf.cadenaSqlServer(${field}) + @"
						 <#break>
					  <#default>
						and ${field}=" + sf.cadenaSqlServer(${field}) + @"
                    </#switch>  
              </#if>
            </#list>
				";
 
          
            reg = db.sql(sqlt);
            if (reg.Read()) retorno=true;
            else retorno=false;
               
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return  retorno;
       } // exists
		 
 
            public ${table}(${table.getListParameters()})
            {

                System.Data.SqlClient.SqlDataReader reg;
                string sqlt;
                dbClass db = new dbClass(ctes.conStringAdoGeneral);
                try
                {
                sqlt = @"select * from ${table} where 1!=0
                <#list table.getFields() as field>
                    <#if (field.getisKey())>
                         <#-- segun el tipo de campo...   -->
                         <#switch field.getType()>
                                  <#case "_int">
                                    and ${field}=" + ${field} +@"
                                     <#break>
                                  <#case "_string">
                                    and ${field}='" + ${field} +@"'
                                     <#break>
                                  <#case "_date">
                                    and ${field}='" + ${field} +@"'
                                     <#break>
                                  <#case "_boolean">
                                    and ${field}=" + ${field};
                                     <#break>
                                  <#default>
                                    and ${field}='" + ${field} +@"'
                        </#switch>  
                  </#if>
                </#list>
				";
                reg = db.sql(sqlt);
                if (reg.Read())
                {
        
                <#list table.getFields() as field>
					 <#-- segun el tipo de campo...   -->
					 <#switch field.getType()>
							  <#case "_int">
								 this.${field} = sf.entero(reg["${field}"].ToString());
								 <#break>
							  <#case "_string">
								 this.${field} = sf.cadena(reg["${field}"].ToString());
								 <#break>
							  <#case "_date">
								 this.${field} = sf.fecha(reg["${field}"].ToString());
								 <#break>
							  <#case "_boolean">
								 this.${field} = sf.boolean(reg["${field}"].ToString());
								 <#break>
							  <#case "_float">
								 this.${field} = sf.doble(reg["${field}"].ToString());
								 <#break>e
							  <#default>
								 this.${field} = sf.cadena(reg["${field}"].ToString());
					</#switch>
                </#list>
           
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }

       } // ${table}
		

<#assign x=0>
<#list table.getRelations() as relation>

  
    <#assign x = x+1>
 
		// devuelve una lista de ${table}
 
 		public static List< ${table} > getListBy${relation.getParentKey()}(int ${relation.getParentKey()})()
		{
		    List< ${table} > lista${table} = new List< ${table} >();
            System.Data.SqlClient.SqlDataReader reg;
            string sqlt;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select ${table.getListWithAllFields()} from ${table}";
            sqlt += " where ${relation.getParentKey()}=" + sf.cadena(${relation.getParentKey()});  
			reg = db.sql(sqlt);
            while (reg.Read())
                {
                ${table} pp = new ${table}();
				<#list table.getFields() as field> 
					 <#-- segun el tipo de campo...   -->
					 <#switch field.getType()>
						  <#case "_int">
							 pp.${field} = sf.entero(reg["${field}"].ToString());
							 <#break>
						  <#case "_string">
							 pp.${field} = sf.cadena(reg["${field}"].ToString());
							 <#break>
						  <#case "_date">
							 pp.${field} = sf.fecha(reg["${field}"].ToString());
							 <#break>
						  <#case "_boolean">
							 pp.${field} = sf.boolean(reg["${field}"].ToString());
							 <#break>
						 <#case "_float">
							 pp.${field} = sf.doble(reg["${field}"].ToString());
							 <#break>
						  <#default>
							 pp.${field} = sf.cadena(reg["${field}"].ToString());
					</#switch>   
				</#list>
               lista${table}.Add(pp);

               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return lista${table};
       }		
 
 
        public static ${table} get${table}By${relation.getParentKey()}(int ${relation.getParentKey()})
        {
            ${table} ${table}x = new ${table}();
            System.Data.SqlClient.SqlDataReader reg;
            string sqlt;
                ${table} obj${table} = new ${table}();


            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select * from ${relation.getChildTable()}";
          
            sqlt += " where ${relation.getParentKey()}=" + sf.cadena(${relation.getParentKey()});  

            reg = db.sql(sqlt);
            if (reg.Read())
            {
          
              <#list table.getFields() as field>

                         <#-- segun el tipo de campo...   -->
                         <#switch field.getType()>
                                  <#case "_int">
                                     obj${table}.${field} = sf.entero(reg["${field}"].ToString());
                                     <#break>
                                  <#case "_string">
                                     obj${table}.${field} = sf.cadena(reg["${field}"].ToString());	  					
                                     <#break>
                                  <#case "_date">
                                    obj${table}.${field} = sf.fecha(reg["${field}"].ToString());
                                     <#break>
                                  <#case "_boolean">
                                     obj${table}.${field} = sf.boolean(reg["${field}"].ToString());
                                     <#break>
                                  <#case "_float">
                                     obj${table}.${field} = sf.doble(reg["${field}"].ToString());
                                     <#break>
                                  <#default>
                                     obj${table}.${field} = sf.cadena(reg["${field}"].ToString());	  					
                        </#switch>  

                </#list>		 
	  			 
                
           
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return  obj${table} ;
       }
    
	
	 public static void delete${relation.getChildTable()}By${relation.getParentKey()} (int ${relation.getParentKey()}x)
	 {
		 dbClass db=new  dbClass(ctes.conStringAdoGeneral);
		 String  sqlt;
		 
		try
		{
		  sqlt = " delete from ${table} where ${relation.getParentKey()}=" + sf.cadena(${relation.getParentKey()}x) ;
			db.ejecutar(sqlt);
		}
		finally
		{db.Dispose();}
		  

	}  
	

</#list>



// funciones extra para campos extra
		<#assign count=0>
		<#list table.getFields() as field>
			<#if (!field.getisKey())>
				<#-- segun el tipo de campo...   -->
				 <#switch field.getTargetType()>
						  <#case "_image">
							public string deleteImg${field}()
							{
								string sqlt;
								string retorno = "";
								dbClassSqlServer db = new dbClassSqlServer(ctes.conStringAdoGeneral);
								try
								{
									sqlt = " update ${table} set";
									sqlt += " ${field}='' ";
									sqlt += " where 1!=0";
									sqlt += " and ${table.getKey()}=" + this.${table.getKey()};
									db.ejecutar(sqlt);
								}
								catch (Exception ex)
								{
									// Argument is optional, no "When" keyword 
								}
								finally
								{
									db.Dispose();
								}
								return retorno;
							}
							 
							 <#break>
						  <#case "_document">
							public string deleteDoc${field}()
							{
								string sqlt;
								string retorno = "";
								dbClass db = new dbClass(ctes.conStringAdoGeneral);
								try
								{
									sqlt = " update ${table} set";
									sqlt += " ${field}='' ";
									sqlt += " where 1!=0";
									sqlt += " and ${table.getKey()}=" + this.${table.getKey()};
									db.ejecutar(sqlt);
								}
								catch (Exception ex)
								{
									// Argument is optional, no "When" keyword 
								}
								finally
								{
									db.Dispose();
								}
								return retorno;
							}
							 
							 <#break>									 
						  <#default>
							
				</#switch>  
			</#if>
			<#assign count = count+1>
		</#list>


}

	




       